function getClass (oParent,class_name){
	var oElement = oParent.getElementsByTagName("*");
	var arr = [];
	for (var i = 0; i < oElement.length; i++) {
		if (oElement[i].className == class_name) {
			arr.push(oElement[i]);
		}
	}
	return arr;
}

function getStyle(obj, name){
    if(obj.currentStyle){
        return obj.currentStyle[name];
    }else{
        return getComputedStyle(obj, false)[name];
    }
}

function startMove(obj, attr, iTarget , s,fn){
    clearInterval(obj.timer);
    obj.timer=setInterval(function (){
        var cur=0;
        if(attr=='opacity'){
            cur=Math.round(parseFloat(getStyle(obj, attr))*100);
        }else{
            cur=parseInt(getStyle(obj, attr));
        }
        if (s) {
            var speed=(iTarget-cur)/s;
        }else{
            var speed=(iTarget-cur)/6;
        }
        speed=speed>0?Math.ceil(speed):Math.floor(speed);
        if(cur==iTarget){
            clearInterval(obj.timer);
        	if (fn) {
        		fn();
        	}
        }else{
            if(attr=='opacity'){
                obj.style.filter='alpha(opacity:'+(cur+speed)+')';
                obj.style.opacity=(cur+speed)/100;
            }else{
                obj.style[attr]=cur+speed+'px';
            }
        }
    }, 20);
}

function show(oParent,oChild){
    oParent.style.background = "white";
    oChild.style.display = "block";
    oParent.style.border = "1px solid #d9d9d9";
    oParent.style.borderBottom = "transparent";
    oParent.style.zIndex = 5;
    oChild.style.zIndex = 4;
}
function hide (oParent,oChild){
    oParent.style.background = "";
    oChild.style.display = "none";
    oParent.style.border = "";
    oParent.style.zIndex = 0;
}
function floors_next_tab (obj,obj2,obj_now,li_length){
    if (obj_now == -2) {
        obj_now = 2;
        startMove(obj[0],"left",2*li_length,5);
        startMove(obj[1],"left",-2*li_length,5,function(){
            obj[1].style.left = 2*li_length + "px";
        });
        startMove(obj[2],"left",-2*li_length,5);
        startMove(obj[3],"left",-2*li_length,5);
    }
    if (obj_now == -1) {
        obj_now = 3;
        startMove(obj[0],"left",li_length,5);
        startMove(obj[1],"left",li_length,5);
        startMove(obj[2],"left",-3*li_length,5,function(){
            obj[2].style.left = li_length + "px";
        });
        startMove(obj[3],"left",-3*li_length,5);
    }
    if (obj_now == 0) {
        startMove(obj[0],"left",0,5);
        startMove(obj[1],"left",0,5);
        startMove(obj[2],"left",0,5);
        startMove(obj[3],"left",-4*li_length,5,function(){
            obj[3].style.left = 0;
        });
    }
    if (obj_now == 1){
        startMove(obj[0],"left",-li_length,5,function(){
            obj[0].style.left = 3*li_length + "px";
        });
        startMove(obj[1],"left",-li_length,5);
        startMove(obj[2],"left",-li_length,5);
        startMove(obj[3],"left",-li_length,5);
    }
    if (obj_now == 2){
        startMove(obj[1],"left",-li_length*obj_now,5,function(){
            obj[1].style.left = (4-obj_now)*li_length + "px";
        });
        startMove(obj[0],"left",li_length*(4-obj_now),5);
        startMove(obj[2],"left",-li_length*(4-obj_now),5);
        startMove(obj[3],"left",-li_length*obj_now,5);
    }
    if (obj_now == 3){
        startMove(obj[2],"left",-li_length*obj_now,5,function(){
            obj[2].style.left = (4-obj_now)*li_length + "px";
        });
        startMove(obj[0],"left",(4-obj_now)*li_length,5);
        startMove(obj[1],"left",(4-obj_now)*li_length,5);
        startMove(obj[3],"left",-li_length*obj_now,5);
    }
    if (obj_now == 4){
        startMove(obj[3],"left",-li_length*obj_now,5,function(){
            obj[3].style.left = (4-obj_now)*li_length + "px";
        });
        startMove(obj[0],"left",(4-obj_now)*li_length,5);
        startMove(obj[1],"left",(4-obj_now)*li_length,5);
        startMove(obj[2],"left",(4-obj_now)*li_length,5);
        obj_now = 0;
    }
    for (var i = 0; i < obj2.length; i++) {
        obj2[i].style.background = "";
    }
    obj2[obj_now].style.background = "#c81623";
    return obj_now;
}
function floors_prev_tab (obj,obj2,obj_now,li_length) {
    if (obj_now == 2) {
        for (var i = 0; i < obj2.length; i++) {
            obj2[i].style.background = "";
        }
        obj2[obj_now].style.background = "#c81623";
        obj[2].style.left = -3*li_length + "px";
        startMove(obj[0],"left",2*li_length,5);
        startMove(obj[1],"left",2*li_length,5);
        startMove(obj[2],"left",-2*li_length,5);
        startMove(obj[3],"left",-2*li_length,5);
    }
    if (obj_now == 1) {
        for (var i = 0; i < obj2.length; i++) {
            obj2[i].style.background = "";
        }
        obj2[obj_now].style.background = "#c81623";
        obj[1].style.left = -2*li_length + "px";
        startMove(obj[0],"left",3*li_length,5);
        startMove(obj[1],"left",-li_length,5);
        startMove(obj[2],"left",-li_length,5);
        startMove(obj[3],"left",-li_length,5);
    }
    if (obj_now == 0) {
        for (var i = 0; i < obj2.length; i++) {
            obj2[i].style.background = "";
        }
        obj2[obj_now].style.background = "#c81623";
        obj[0].style.left = -li_length + "px";
        startMove(obj[0],"left",0,5);
        startMove(obj[1],"left",0,5);
        startMove(obj[2],"left",0,5);
        startMove(obj[3],"left",0,5);
    }
    if (obj_now == -1) {
        obj_now = 3;
        for (var i = 0; i < obj2.length; i++) {
            obj2[i].style.background = "";
        }
        obj2[obj_now].style.background = "#c81623";
        obj[3].style.left = -4*li_length+"px";
        startMove(obj[3],"left",-obj_now*li_length);
        startMove(obj[2],"left",(4-obj_now)*li_length,5);
        startMove(obj[1],"left",(4-obj_now)*li_length,5);
        startMove(obj[0],"left",(4-obj_now)*li_length,5);
        obj_now = -1;
    }
    if (obj_now == -2) {
        obj_now = 2;
        for (var i = 0; i < obj2.length; i++) {
            obj2[i].style.background = "";
        }
        obj2[obj_now].style.background = "#c81623";
        obj[2].style.left = -3*li_length+"px";
        startMove(obj[3],"left",-obj_now*li_length,5);
        startMove(obj[2],"left",-(4-obj_now)*li_length,5);
        startMove(obj[1],"left",(4-obj_now)*li_length,5);
        startMove(obj[0],"left",(4-obj_now)*li_length,5);
        obj_now = -2;
    }
    if (obj_now == -3) {
        obj_now = 1;
        for (var i = 0; i < obj2.length; i++) {
            obj2[i].style.background = "";
        }
        obj2[obj_now].style.background = "#c81623";
        obj[1].style.left = -2*li_length+"px";
        startMove(obj[3],"left",-obj_now*li_length,5);
        startMove(obj[2],"left",-li_length,5);
        startMove(obj[1],"left",-li_length,5);
        startMove(obj[0],"left",(4-obj_now)*li_length,5);
        obj_now = -3;
    }
    if (obj_now == -4) {
        obj_now = 0;
        for (var i = 0; i < obj2.length; i++) {
            obj2[i].style.background = "";
        }
        obj2[obj_now].style.background = "#c81623";
        obj[0].style.left = -li_length+"px";
        startMove(obj[3],"left",-obj_now*li_length,5);
        startMove(obj[2],"left",0,5);
        startMove(obj[1],"left",0,5);
        startMove(obj[0],"left",0,5);
        obj_now = 0;
    }
    return obj_now;
}
function floors_timer(obj,timer,next,prev){
    timer = setInterval(next.onclick,4000);
    obj.onmouseover = function (){
        clearInterval(timer);
        next.style.display = "block";
        prev.style.display = "block";
    };
    obj.onmouseout = function (){
        timer = setInterval(next.onclick,4000);
        next.style.display = "none";
        prev.style.display = "none";
    };
    next.onmouseover = function (){
        clearInterval(timer);
        next.style.display = "block";
        prev.style.display = "block";  
    };
    next.onmouseout = function (){
        timer = setInterval(next.onclick,4000);
        next.style.display = "none";
        prev.style.display = "none";  
    };
    prev.onmouseover = function (){
        clearInterval(timer);
        next.style.display = "block";
        prev.style.display = "block";  
    };
    prev.onmouseout = function (){
        timer = setInterval(next.onclick,4000);
        next.style.display = "none";
        prev.style.display = "none";  
    };
}
function floors_sort (ul,sort_li,sort_a,sort_now){
    for (var i = 0; i < sort_li.length; i++) {
        sort_li[i].style.border = "";
        sort_a[i].style.color = "";
        sort_a[i].style.borderRight = "";
        ul[i].style.display = "";
        if (i == 0) {
            ul[i].style.display = "none";
        }
    }
    sort_a[sort_now].style.borderRight = "transparent";
    sort_a[sort_now].style.color = "#c81623";
    sort_li[sort_now].style.border = "1px solid #c81623";
    sort_li[sort_now].style.borderTop = "2px solid #c81623";
    sort_li[sort_now].style.borderBottom = "transparent";
    ul[sort_now].style.display = "block";
}
